package cvo.chess.client.entities.game;

import cvo.chess.client.entities.GameFacade;
import cvo.chess.client.entities.armies.Piece;
import cvo.chess.client.entities.chessboard.ChessboardCoordinate;

public abstract class Army {

	GameFacade gf;

	public Army(GameFacade gf) {
		this.gf = gf;
	}

	public void Init() throws Exception {
		IChessboard board = this.gf.getBoard();
		if (board != null) {
			placePiecesOnBoard();
		} else {
			throw new Exception("No chessboard available to place pieces on.");
		}
	}

	protected abstract void placePiecesOnBoard() throws Exception;

	protected void placePieceOnBoard(Piece piece, ChessboardCoordinate position)
			throws Exception {
		gf.setPieceAtPosition(piece, position);
	}

	// Helper method.
	protected ChessboardCoordinate createCoordinate(String a1notation) {
		return new ChessboardCoordinate(this.gf.getBoard(), a1notation);
	}
}
